{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Objective : Working on Text Data\n",
    "\n",
    "<hr>\n",
    "\n",
    "1. Introduction\n",
    "2. Concat, Split & Join \n",
    "3. Contains, Find\n",
    "4. Cleaning Punchuations\n",
    "5. Checking contents of String Data\n",
    "6. String Manipulation\n",
    "\n",
    "<hr>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Introduction\n",
    "* Columns many times contain string data. \n",
    "* And, string data may always not be in best of their hygine.\n",
    "* Pandas provide rich api's to make task easier using .str functions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Concat, Split & Join"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame({'A':['a','b','c','d']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>a</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>b</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>c</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>d</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A\n",
       "0  a\n",
       "1  b\n",
       "2  c\n",
       "3  d"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'a b c d'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.A.str.cat(sep=' ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    a1\n",
       "1    b2\n",
       "2    c3\n",
       "3    d4\n",
       "Name: A, dtype: object"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.A.str.cat(['1','2','3','4'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "horror_data = pd.read_csv('../Data/horror-train.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "horror_data = horror_data.iloc[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>text</th>\n",
       "      <th>author</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>id26305</td>\n",
       "      <td>This process, however, afforded me no means of...</td>\n",
       "      <td>EAP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>id17569</td>\n",
       "      <td>It never once occurred to me that the fumbling...</td>\n",
       "      <td>HPL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>id11008</td>\n",
       "      <td>In his left hand was a gold snuff box, from wh...</td>\n",
       "      <td>EAP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>id27763</td>\n",
       "      <td>How lovely is spring As we looked from Windsor...</td>\n",
       "      <td>MWS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>id12958</td>\n",
       "      <td>Finding nothing else, not even gold, the Super...</td>\n",
       "      <td>HPL</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>id22965</td>\n",
       "      <td>A youth passed in solitude, my best years spen...</td>\n",
       "      <td>MWS</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>id09674</td>\n",
       "      <td>The astronomer, perhaps, at this point, took r...</td>\n",
       "      <td>EAP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>id13515</td>\n",
       "      <td>The surcingle hung in ribands from my body.</td>\n",
       "      <td>EAP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>id19322</td>\n",
       "      <td>I knew that you could not say to yourself 'ste...</td>\n",
       "      <td>EAP</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>id00912</td>\n",
       "      <td>I confess that neither the structure of langua...</td>\n",
       "      <td>MWS</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        id                                               text author\n",
       "0  id26305  This process, however, afforded me no means of...    EAP\n",
       "1  id17569  It never once occurred to me that the fumbling...    HPL\n",
       "2  id11008  In his left hand was a gold snuff box, from wh...    EAP\n",
       "3  id27763  How lovely is spring As we looked from Windsor...    MWS\n",
       "4  id12958  Finding nothing else, not even gold, the Super...    HPL\n",
       "5  id22965  A youth passed in solitude, my best years spen...    MWS\n",
       "6  id09674  The astronomer, perhaps, at this point, took r...    EAP\n",
       "7  id13515        The surcingle hung in ribands from my body.    EAP\n",
       "8  id19322  I knew that you could not say to yourself 'ste...    EAP\n",
       "9  id00912  I confess that neither the structure of langua...    MWS"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    [This, process,, however,, afforded, me, no, m...\n",
       "1    [It, never, once, occurred, to, me, that, the,...\n",
       "2    [In, his, left, hand, was, a, gold, snuff, box...\n",
       "3    [How, lovely, is, spring, As, we, looked, from...\n",
       "4    [Finding, nothing, else,, not, even, gold,, th...\n",
       "5    [A, youth, passed, in, solitude,, my, best, ye...\n",
       "6    [The, astronomer,, perhaps,, at, this, point,,...\n",
       "7    [The, surcingle, hung, in, ribands, from, my, ...\n",
       "8    [I, knew, that, you, could, not, say, to, your...\n",
       "9    [I, confess, that, neither, the, structure, of...\n",
       "Name: text, dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data.text.str.split()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>13</th>\n",
       "      <th>14</th>\n",
       "      <th>15</th>\n",
       "      <th>16</th>\n",
       "      <th>17</th>\n",
       "      <th>18</th>\n",
       "      <th>19</th>\n",
       "      <th>20</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>This</td>\n",
       "      <td>process,</td>\n",
       "      <td>however,</td>\n",
       "      <td>afforded</td>\n",
       "      <td>me</td>\n",
       "      <td>no</td>\n",
       "      <td>means</td>\n",
       "      <td>of</td>\n",
       "      <td>ascertaining</td>\n",
       "      <td>the</td>\n",
       "      <td>...</td>\n",
       "      <td>of</td>\n",
       "      <td>my</td>\n",
       "      <td>dungeon;</td>\n",
       "      <td>as</td>\n",
       "      <td>I</td>\n",
       "      <td>might</td>\n",
       "      <td>make</td>\n",
       "      <td>its</td>\n",
       "      <td>circuit,</td>\n",
       "      <td>and return to the point whence I set out, with...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>It</td>\n",
       "      <td>never</td>\n",
       "      <td>once</td>\n",
       "      <td>occurred</td>\n",
       "      <td>to</td>\n",
       "      <td>me</td>\n",
       "      <td>that</td>\n",
       "      <td>the</td>\n",
       "      <td>fumbling</td>\n",
       "      <td>might</td>\n",
       "      <td>...</td>\n",
       "      <td>a</td>\n",
       "      <td>mere</td>\n",
       "      <td>mistake.</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>In</td>\n",
       "      <td>his</td>\n",
       "      <td>left</td>\n",
       "      <td>hand</td>\n",
       "      <td>was</td>\n",
       "      <td>a</td>\n",
       "      <td>gold</td>\n",
       "      <td>snuff</td>\n",
       "      <td>box,</td>\n",
       "      <td>from</td>\n",
       "      <td>...</td>\n",
       "      <td>as</td>\n",
       "      <td>he</td>\n",
       "      <td>capered</td>\n",
       "      <td>down</td>\n",
       "      <td>the</td>\n",
       "      <td>hill,</td>\n",
       "      <td>cutting</td>\n",
       "      <td>all</td>\n",
       "      <td>manner</td>\n",
       "      <td>of fantastic steps, he took snuff incessantly ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>How</td>\n",
       "      <td>lovely</td>\n",
       "      <td>is</td>\n",
       "      <td>spring</td>\n",
       "      <td>As</td>\n",
       "      <td>we</td>\n",
       "      <td>looked</td>\n",
       "      <td>from</td>\n",
       "      <td>Windsor</td>\n",
       "      <td>Terrace</td>\n",
       "      <td>...</td>\n",
       "      <td>the</td>\n",
       "      <td>sixteen</td>\n",
       "      <td>fertile</td>\n",
       "      <td>counties</td>\n",
       "      <td>spread</td>\n",
       "      <td>beneath,</td>\n",
       "      <td>speckled</td>\n",
       "      <td>by</td>\n",
       "      <td>happy</td>\n",
       "      <td>cottages and wealthier towns, all looked as in...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Finding</td>\n",
       "      <td>nothing</td>\n",
       "      <td>else,</td>\n",
       "      <td>not</td>\n",
       "      <td>even</td>\n",
       "      <td>gold,</td>\n",
       "      <td>the</td>\n",
       "      <td>Superintendent</td>\n",
       "      <td>abandoned</td>\n",
       "      <td>his</td>\n",
       "      <td>...</td>\n",
       "      <td>but</td>\n",
       "      <td>a</td>\n",
       "      <td>perplexed</td>\n",
       "      <td>look</td>\n",
       "      <td>occasionally</td>\n",
       "      <td>steals</td>\n",
       "      <td>over</td>\n",
       "      <td>his</td>\n",
       "      <td>countenance</td>\n",
       "      <td>as he sits thinking at his desk.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>A</td>\n",
       "      <td>youth</td>\n",
       "      <td>passed</td>\n",
       "      <td>in</td>\n",
       "      <td>solitude,</td>\n",
       "      <td>my</td>\n",
       "      <td>best</td>\n",
       "      <td>years</td>\n",
       "      <td>spent</td>\n",
       "      <td>under</td>\n",
       "      <td>...</td>\n",
       "      <td>gentle</td>\n",
       "      <td>and</td>\n",
       "      <td>feminine</td>\n",
       "      <td>fosterage,</td>\n",
       "      <td>has</td>\n",
       "      <td>so</td>\n",
       "      <td>refined</td>\n",
       "      <td>the</td>\n",
       "      <td>groundwork</td>\n",
       "      <td>of my character that I cannot overcome an inte...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>The</td>\n",
       "      <td>astronomer,</td>\n",
       "      <td>perhaps,</td>\n",
       "      <td>at</td>\n",
       "      <td>this</td>\n",
       "      <td>point,</td>\n",
       "      <td>took</td>\n",
       "      <td>refuge</td>\n",
       "      <td>in</td>\n",
       "      <td>the</td>\n",
       "      <td>...</td>\n",
       "      <td>of</td>\n",
       "      <td>non</td>\n",
       "      <td>luminosity;</td>\n",
       "      <td>and</td>\n",
       "      <td>here</td>\n",
       "      <td>analogy</td>\n",
       "      <td>was</td>\n",
       "      <td>suddenly</td>\n",
       "      <td>let</td>\n",
       "      <td>fall.</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>The</td>\n",
       "      <td>surcingle</td>\n",
       "      <td>hung</td>\n",
       "      <td>in</td>\n",
       "      <td>ribands</td>\n",
       "      <td>from</td>\n",
       "      <td>my</td>\n",
       "      <td>body.</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>I</td>\n",
       "      <td>knew</td>\n",
       "      <td>that</td>\n",
       "      <td>you</td>\n",
       "      <td>could</td>\n",
       "      <td>not</td>\n",
       "      <td>say</td>\n",
       "      <td>to</td>\n",
       "      <td>yourself</td>\n",
       "      <td>'stereotomy'</td>\n",
       "      <td>...</td>\n",
       "      <td>being</td>\n",
       "      <td>brought</td>\n",
       "      <td>to</td>\n",
       "      <td>think</td>\n",
       "      <td>of</td>\n",
       "      <td>atomies,</td>\n",
       "      <td>and</td>\n",
       "      <td>thus</td>\n",
       "      <td>of</td>\n",
       "      <td>the theories of Epicurus; and since, when we d...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>I</td>\n",
       "      <td>confess</td>\n",
       "      <td>that</td>\n",
       "      <td>neither</td>\n",
       "      <td>the</td>\n",
       "      <td>structure</td>\n",
       "      <td>of</td>\n",
       "      <td>languages,</td>\n",
       "      <td>nor</td>\n",
       "      <td>the</td>\n",
       "      <td>...</td>\n",
       "      <td>of</td>\n",
       "      <td>governments,</td>\n",
       "      <td>nor</td>\n",
       "      <td>the</td>\n",
       "      <td>politics</td>\n",
       "      <td>of</td>\n",
       "      <td>various</td>\n",
       "      <td>states</td>\n",
       "      <td>possessed</td>\n",
       "      <td>attractions for me.</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        0            1         2         3          4          5       6   \\\n",
       "0     This     process,  however,  afforded         me         no   means   \n",
       "1       It        never      once  occurred         to         me    that   \n",
       "2       In          his      left      hand        was          a    gold   \n",
       "3      How       lovely        is    spring         As         we  looked   \n",
       "4  Finding      nothing     else,       not       even      gold,     the   \n",
       "5        A        youth    passed        in  solitude,         my    best   \n",
       "6      The  astronomer,  perhaps,        at       this     point,    took   \n",
       "7      The    surcingle      hung        in    ribands       from      my   \n",
       "8        I         knew      that       you      could        not     say   \n",
       "9        I      confess      that   neither        the  structure      of   \n",
       "\n",
       "               7             8             9   ...      11            12  \\\n",
       "0              of  ascertaining           the  ...      of            my   \n",
       "1             the      fumbling         might  ...       a          mere   \n",
       "2           snuff          box,          from  ...      as            he   \n",
       "3            from       Windsor       Terrace  ...     the       sixteen   \n",
       "4  Superintendent     abandoned           his  ...     but             a   \n",
       "5           years         spent         under  ...  gentle           and   \n",
       "6          refuge            in           the  ...      of           non   \n",
       "7           body.          None          None  ...    None          None   \n",
       "8              to      yourself  'stereotomy'  ...   being       brought   \n",
       "9      languages,           nor           the  ...      of  governments,   \n",
       "\n",
       "            13          14            15        16        17        18  \\\n",
       "0     dungeon;          as             I     might      make       its   \n",
       "1     mistake.        None          None      None      None      None   \n",
       "2      capered        down           the     hill,   cutting       all   \n",
       "3      fertile    counties        spread  beneath,  speckled        by   \n",
       "4    perplexed        look  occasionally    steals      over       his   \n",
       "5     feminine  fosterage,           has        so   refined       the   \n",
       "6  luminosity;         and          here   analogy       was  suddenly   \n",
       "7         None        None          None      None      None      None   \n",
       "8           to       think            of  atomies,       and      thus   \n",
       "9          nor         the      politics        of   various    states   \n",
       "\n",
       "            19                                                 20  \n",
       "0     circuit,  and return to the point whence I set out, with...  \n",
       "1         None                                               None  \n",
       "2       manner  of fantastic steps, he took snuff incessantly ...  \n",
       "3        happy  cottages and wealthier towns, all looked as in...  \n",
       "4  countenance                   as he sits thinking at his desk.  \n",
       "5   groundwork  of my character that I cannot overcome an inte...  \n",
       "6          let                                              fall.  \n",
       "7         None                                               None  \n",
       "8           of  the theories of Epicurus; and since, when we d...  \n",
       "9    possessed                                attractions for me.  \n",
       "\n",
       "[10 rows x 21 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data.text.str.split(expand=True,n=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = horror_data.text.str.split()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    This process, however, afforded me no means of...\n",
       "1    It never once occurred to me that the fumbling...\n",
       "2    In his left hand was a gold snuff box, from wh...\n",
       "3    How lovely is spring As we looked from Windsor...\n",
       "4    Finding nothing else, not even gold, the Super...\n",
       "5    A youth passed in solitude, my best years spen...\n",
       "6    The astronomer, perhaps, at this point, took r...\n",
       "7          The surcingle hung in ribands from my body.\n",
       "8    I knew that you could not say to yourself 'ste...\n",
       "9    I confess that neither the structure of langua...\n",
       "Name: text, dtype: object"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.str.join(sep=' ')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Understanding contains, find & index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1    False\n",
       "2    False\n",
       "3    False\n",
       "4    False\n",
       "5    False\n",
       "6    False\n",
       "7    False\n",
       "8    False\n",
       "9    False\n",
       "Name: text, dtype: bool"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data.text.str.contains('This')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1    False\n",
       "2     True\n",
       "3    False\n",
       "4     True\n",
       "5     True\n",
       "6     True\n",
       "7    False\n",
       "8     True\n",
       "9    False\n",
       "Name: text, dtype: bool"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data.text.str.contains('his')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "1   -1\n",
       "2   -1\n",
       "3   -1\n",
       "4   -1\n",
       "5   -1\n",
       "6   -1\n",
       "7   -1\n",
       "8   -1\n",
       "9   -1\n",
       "Name: text, dtype: int64"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data.text.str.find('This')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     2\n",
       "1    64\n",
       "2     4\n",
       "3    11\n",
       "4    67\n",
       "Name: text, dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data[:5].text.str.index('is')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame({'Name':['Abc','Def','Jkl'], 'Email':['awidgmail.com', ' def@gmail.com', 'jkl@yahoo.com']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Email</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Abc</td>\n",
       "      <td>awidgmail.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Def</td>\n",
       "      <td>def@gmail.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Jkl</td>\n",
       "      <td>jkl@yahoo.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Name           Email\n",
       "0  Abc   awidgmail.com\n",
       "1  Def   def@gmail.com\n",
       "2  Jkl   jkl@yahoo.com"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    False\n",
       "1     True\n",
       "2     True\n",
       "Name: Email, dtype: bool"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.Email.str.contains(r'\\w+@\\w+')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     awidgmail.com\n",
       "1     def&gmail.com\n",
       "2     jkl&yahoo.com\n",
       "Name: Email, dtype: object"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.Email.str.replace(pat='@',repl='&')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. Cleaning Punchuations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import string\n",
    "table = str.maketrans('', '', string.punctuation)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    This process however afforded me no means of a...\n",
       "1    It never once occurred to me that the fumbling...\n",
       "2    In his left hand was a gold snuff box from whi...\n",
       "3    How lovely is spring As we looked from Windsor...\n",
       "4    Finding nothing else not even gold the Superin...\n",
       "5    A youth passed in solitude my best years spent...\n",
       "6    The astronomer perhaps at this point took refu...\n",
       "7           The surcingle hung in ribands from my body\n",
       "8    I knew that you could not say to yourself ster...\n",
       "9    I confess that neither the structure of langua...\n",
       "Name: text, dtype: object"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "horror_data.text.str.translate(table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "horror_data_tf = horror_data.text.str.translate(table)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "horror_data_tf = horror_data_tf.str.lower()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  5. Check for string contents\n",
    "* isalnum()\tEquivalent to str.isalnum\n",
    "* isalpha()\tEquivalent to str.isalpha\n",
    "* isdigit()\tEquivalent to str.isdigit\n",
    "* isspace()\tEquivalent to str.isspace\n",
    "* islower()\tEquivalent to str.islower\n",
    "* isupper()\tEquivalent to str.isupper\n",
    "* istitle()\tEquivalent to str.istitle\n",
    "* isnumeric()\tEquivalent to str.isnumeric\n",
    "* isdecimal()\tEquivalent to str.isdecimal"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame({'A':['1234','123ab','abcde']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>123ab</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>abcde</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       A\n",
       "0   1234\n",
       "1  123ab\n",
       "2  abcde"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Returns only rows which contain digit"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1234</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      A\n",
       "0  1234"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.A.str.isdigit()]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Returns only rows which is alphabets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>abcde</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       A\n",
       "2  abcde"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.A.str.isalpha()]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 6. String Manipulation\n",
    "* slice()\tSlice each string in the Series\n",
    "* slice_replace()\tReplace slice in each string with passed value\n",
    "* count()\tCount occurrences of pattern\n",
    "* startswith()\tEquivalent to str.startswith(pat) for each element\n",
    "* endswith()\tEquivalent to str.endswith(pat) for each element\n",
    "* findall()\tCompute list of all occurrences of pattern/regex for each string\n",
    "* match()\tCall re.match on each element, returning matched groups as list\n",
    "* extract()\tCall re.search on each element, returning DataFrame with one row for each element and one column for each regex \n",
    "* extractall()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame({'Name':['Rush','Riba','Kunal','Pruthvi'],\n",
    "                   'Email':['rush@edyoda.com','riba@edyoda.com','kunal@edyoda.com','pruthvi@edyoda.com']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Email</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rush</td>\n",
       "      <td>rush@edyoda.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Riba</td>\n",
       "      <td>riba@edyoda.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Kunal</td>\n",
       "      <td>kunal@edyoda.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Pruthvi</td>\n",
       "      <td>pruthvi@edyoda.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Name               Email\n",
       "0     Rush     rush@edyoda.com\n",
       "1     Riba     riba@edyoda.com\n",
       "2    Kunal    kunal@edyoda.com\n",
       "3  Pruthvi  pruthvi@edyoda.com"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['Username'] = df.Email.str.slice(start = 0, step=2, stop=-11)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Email</th>\n",
       "      <th>Username</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rush</td>\n",
       "      <td>rush@edyoda.com</td>\n",
       "      <td>rs</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Riba</td>\n",
       "      <td>riba@edyoda.com</td>\n",
       "      <td>rb</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Kunal</td>\n",
       "      <td>kunal@edyoda.com</td>\n",
       "      <td>knl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Pruthvi</td>\n",
       "      <td>pruthvi@edyoda.com</td>\n",
       "      <td>puhi</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Name               Email Username\n",
       "0     Rush     rush@edyoda.com       rs\n",
       "1     Riba     riba@edyoda.com       rb\n",
       "2    Kunal    kunal@edyoda.com      knl\n",
       "3  Pruthvi  pruthvi@edyoda.com     puhi"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Email</th>\n",
       "      <th>Username</th>\n",
       "      <th>UpdatedEmail</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rush</td>\n",
       "      <td>rush@edyoda.com</td>\n",
       "      <td>rs</td>\n",
       "      <td>rush@zekelabs.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Riba</td>\n",
       "      <td>riba@edyoda.com</td>\n",
       "      <td>rb</td>\n",
       "      <td>riba@zekelabs.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Kunal</td>\n",
       "      <td>kunal@edyoda.com</td>\n",
       "      <td>knl</td>\n",
       "      <td>kunal@zekelabs.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Pruthvi</td>\n",
       "      <td>pruthvi@edyoda.com</td>\n",
       "      <td>puhi</td>\n",
       "      <td>pruthvi@zekelabs.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Name               Email Username          UpdatedEmail\n",
       "0     Rush     rush@edyoda.com       rs     rush@zekelabs.com\n",
       "1     Riba     riba@edyoda.com       rb     riba@zekelabs.com\n",
       "2    Kunal    kunal@edyoda.com      knl    kunal@zekelabs.com\n",
       "3  Pruthvi  pruthvi@edyoda.com     puhi  pruthvi@zekelabs.com"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['UpdatedEmail'] = df.Email.str.slice_replace(start=-11, repl='@zekelabs.com')\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Altering value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.at[2,'Email'] = 'kunal@everywhere.com'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Email</th>\n",
       "      <th>Username</th>\n",
       "      <th>UpdatedEmail</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Rush</td>\n",
       "      <td>rush@edyoda.com</td>\n",
       "      <td>rs</td>\n",
       "      <td>rush@zekelabs.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Riba</td>\n",
       "      <td>riba@edyoda.com</td>\n",
       "      <td>rb</td>\n",
       "      <td>riba@zekelabs.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Kunal</td>\n",
       "      <td>kunal@everywhere.com</td>\n",
       "      <td>knl</td>\n",
       "      <td>kunal@zekelabs.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Pruthvi</td>\n",
       "      <td>pruthvi@edyoda.com</td>\n",
       "      <td>puhi</td>\n",
       "      <td>pruthvi@zekelabs.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Name                 Email Username          UpdatedEmail\n",
       "0     Rush       rush@edyoda.com       rs     rush@zekelabs.com\n",
       "1     Riba       riba@edyoda.com       rb     riba@zekelabs.com\n",
       "2    Kunal  kunal@everywhere.com      knl    kunal@zekelabs.com\n",
       "3  Pruthvi    pruthvi@edyoda.com     puhi  pruthvi@zekelabs.com"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Filtering based domain name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     True\n",
       "1     True\n",
       "2    False\n",
       "3     True\n",
       "Name: Email, dtype: bool"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.Email.str.match('[\\w]+@edyoda.com')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* Extract text based on certain pattern"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>rush</td>\n",
       "      <td>edyoda.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>riba</td>\n",
       "      <td>edyoda.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>kunal</td>\n",
       "      <td>everywhere.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>pruthvi</td>\n",
       "      <td>edyoda.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         0               1\n",
       "0     rush      edyoda.com\n",
       "1     riba      edyoda.com\n",
       "2    kunal  everywhere.com\n",
       "3  pruthvi      edyoda.com"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.Email.str.extract('([\\w]*)@([\\w.]*)')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
